﻿<Page x:Class="PasswordProvider.View.LogOnSiteDetailsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:lib="clr-namespace:PasswordProvider.View.Library"
    xmlns:view="clr-namespace:PasswordProvider.View"
    Title="{Binding DisplayName}"
    ToolTip="{Binding ToolTip}">
    <Page.Resources>
        <DataTemplate x:Key="LoginSiteDataTemplate">
            <TabControl DockPanel.Dock="Top">
                <TabItem Header="{Binding IdentityGroupDisplayName}">
                    <StackPanel Margin="10,0">
                        <TextBlock Text="{Binding Name.DisplayName}"/>
                    <Grid>
                        <TextBox Name="nameTextBox" VerticalAlignment="Center"
                                 ToolTip="{Binding Name.ToolTip}"
                                 Text="{Binding Name.Text, UpdateSourceTrigger=PropertyChanged}"
                                     />
                        <!-- I Like the image but it ruins the load time for the page. -->
                        <!--<Image Name="iconImage" Margin="2,0,0,0" MaxHeight="16" MaxWidth="16"
                               HorizontalAlignment="Left" VerticalAlignment="Center"
                               Source="{Binding IconUrl}"
                                   />-->
                    </Grid>

                    <TextBlock Text="{Binding Url.DisplayName}" Margin="0,10,0,0" />
                    <TextBox TextWrapping="WrapWithOverflow"
                             ToolTip="{Binding Url.ToolTip}"
                             Text="{Binding Url.Text, UpdateSourceTrigger=PropertyChanged}"
                                 />

                    <TextBlock Text="{Binding Description.DisplayName}"  Margin="0,10,0,0" />
                    <TextBox MinHeight="50" TextWrapping="Wrap" AcceptsReturn="True"
                             ToolTip="{Binding Description.ToolTip}"
                             Text="{Binding Description.Text, UpdateSourceTrigger=PropertyChanged}"
                                 />

                    <TextBlock Text="{Binding Tags.DisplayName}" Margin="0,10,3,0" />
                    <lib:MultiComboBox SelectionMode="Multiple"
                         ItemsSource="{Binding Tags.List}"
                         SelectedItems="{Binding Tags.SelectedItems}"
                         IsCreateNewEnabled="True"
                         HorizontalContentAlignment="Left"
                         DisplaySeparator=", "
                             />

                </StackPanel>
                </TabItem>
                <TabItem Header="{Binding LogOnGroupDisplayName}">
                    <Grid Margin="10,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Row="0" VerticalAlignment="Bottom" Margin="0,10,0,0"
                               Text="{Binding LogOnId.DisplayName}"
                                   />
                    <TextBox Grid.Row="1" Margin="10,0,0,0" VerticalAlignment="Top"
                             ToolTip="{Binding Path=LogOnId.ToolTip}"
                             Text="{Binding LogOnId.Text, UpdateSourceTrigger=PropertyChanged}"
                                 />

                    <TextBlock Grid.Row="2" Margin="0,10,0,0"
                               Text="{Binding Password.DisplayName}"/>
                    <lib:EncryptedValueEditBox Grid.Row="3" Margin="10,0,0,0"
                                                ToolTip="{Binding Password.ToolTip}"
                                                IsEnabled="{Binding Password.IsEnabled}"
                                                IsReadOnly="{Binding Password.IsReadOnly}"
                                                DisplayString="{Binding Password.DisplayString, Mode=TwoWay}"
                                                    />

                    <CheckBox Grid.Row="4" Margin="10,10,0,0"
                              Content="{Binding ShowClearText.DisplayName}"
                              IsChecked="{Binding ShowClearText.IsChecked}"
                              IsEnabled="{Binding ShowClearText.IsEnabled}"
                                  />
                    <CheckBox Grid.Row="6" Margin="10,0,0,0"
                              Content="{Binding ShowPasswordGenerator.DisplayName}"
                              IsChecked="{Binding ShowPasswordGenerator.IsChecked}"
                              IsEnabled="{Binding ShowPasswordGenerator.IsEnabled}"
                             />
                    <lib:PasswordGeneratorControl Grid.Row="7" VerticalAlignment="Top" Margin="15"
                            Visibility="{Binding PasswordGenerator.Visibility}"
                            BorderBrush="{DynamicResource DetailBrush}" BorderThickness="2"
                            GeneratedPassword="{Binding PasswordGenerator.Text, Mode=OneWayToSource}"
                                />
                </Grid>

                </TabItem>
            </TabControl>
            <!--<DataTemplate.Triggers>
                <Trigger SourceName="iconImage" Property="Source" Value="{x:Null}">
                    <Setter TargetName="nameTextBox" Property="Padding" Value="0"/>
                </Trigger>
            </DataTemplate.Triggers>-->
        </DataTemplate>
        
    </Page.Resources>
    <DockPanel>   
        <ContentPresenter DockPanel.Dock="Top" Content="{Binding}" ContentTemplate="{StaticResource LoginSiteDataTemplate}" />            
        <WrapPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" VerticalAlignment="Bottom">
            <Button Width="50" Margin="5" 
                    IsDefault="{Binding CancelCommand.IsDefault}" 
                    IsEnabled="{Binding CancelCommand.IsEnabled}"
		                Command="{Binding CancelCommand.Command}" 
                    Content="{Binding CancelCommand.DisplayName}"
                    />
            <Button Width="50" Margin="5" 
                    Command="{Binding CommitChangesCommand.Command}" 
                    Content="{Binding CommitChangesCommand.DisplayName}"
                    IsEnabled="{Binding CommitChangesCommand.IsEnabled}"
                    IsDefault="{Binding CommitChangesCommand.IsDefault}"
                    />
        </WrapPanel>
    </DockPanel>
        
</Page>
